package com.znzz.service;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.IService;
import com.znzz.domain.User;
import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;

@SpringBootTest//测试类
public class UserServiceTestCase {
    @Autowired
    private IUserService userService;

    @Test
    void testGetById() {
        System.out.println(userService.getById("720191053070"));
    }

    @Test
    void save() {
        User user = new User();
        user.setName("清清");
        user.setPassword("66666666");
        user.setAddress("上海");
        user.setSex("男");
        System.out.println(userService.save(user));
    }

    @Test
    void testGetAll() {
        userService.list();
    }

    @Test
    void testDelete() {
        userService.removeById("815ffba8926712aa3d304e75dfd72b89");
    }

    @Test
    void testUpdate() {
        User user = new User();
        user.setName("IU");
        user.setPassword("66666666");
        user.setAddress("韩国");
        user.setSex("女");
        user.setId("720191053070");
        userService.updateById(user);
    }

    @Test
    void getByPages() {
        IPage<User> page = new Page<>(1, 5);
        page = userService.page(page);
        System.out.println(page.getCurrent());
        System.out.println(page.getSize());
        System.out.println(page.getTotal());
        System.out.println(page.getPages());
        System.out.println(page.getRecords());
        page.getRecords().forEach(System.out::println);
    }
}
